package com.antaohua.tools.api.controller;

import java.io.IOException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.antaohua.framework.web.controller.BaseController;
import com.antaohua.framework.web.utils.JsonResult;
import com.antaohua.tools.api.entity.InterfaceProviderEntity;
import com.antaohua.tools.api.service.InterfaceProviderService;
import com.antaohua.tools.framework.base.exception.InsertEntityException;
import com.antaohua.tools.framework.base.utils.Base64ToImage;

@Controller
@RequestMapping("api/provider")
public class InterfaceProviderController extends BaseController<InterfaceProviderEntity>{

	@Autowired
	Base64ToImage base64ToImage;


	@RequestMapping(path="save_provider")
	public @ResponseBody String save(InterfaceProviderEntity entity,String iconImager)throws InsertEntityException,IOException{

		String iconPath = null;
		if(iconImager!=null&&iconImager.trim().length()>1){
			iconPath = base64ToImage.base64ToImage(iconImager);

			entity.setIcon(iconPath);
		}
		service.save(entity);
		return "true";
	}

	@RequestMapping(path="provider_code_values")
	public @ResponseBody List<String> providerCodeValues(){
		return ((InterfaceProviderService) service).getProviderCodeValues();
	}

}
